local skill = fk.CreateSkill{
  name = "#diy__ice_damage_skill",
}

-- 已弃用
skill:addEffect(fk.DamageCaused, {
  --global = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and data.damageType == fk.IceDamage and
      not (data.card and data.card.name == "ice__slash") and
      not data.chain and not data.to:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local extra = data.extra_data
    local choices = { "damage", "discard" }
    if extra and extra.ice_prohibit then
      local prohibit = extra.ice_prohibit
      if table.contains(prohibit, "damage") then
        table.removeOne(choices, "damage")
      end
      if table.contains(prohibit, "discard") then
        table.removeOne(choices, "discard")
      end
    end
    if not table.contains(choices, "damage") then
      event:setCostData(self, {tos = {data.to}, prohibit_discard = not table.contains(choices, "discard")})
      return true
    elseif not table.contains(choices, "discard") then
      return false
    elseif room:askToSkillInvoke(player, {
      skill_name = skill.name,
      prompt = "#diy__ice_damage_skill-invoke::"..data.to.id,
    }) then
      event:setCostData(self, {tos = {data.to}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local extra = event:getCostData(self)
    data:preventDamage()
    if extra.prohibit_discard then return end
    for i = 1, 2 do
      if data.to:isNude() or data.to.dead or player.dead then break end
      local card = room:askToChooseCard(player, {
        target = data.to,
        flag = "he",
        skill_name = skill.name,
      })
      room:throwCard(card, skill.name, data.to, player)
    end
  end,
})
Fk:loadTranslationTable{
  ["#diy__ice_damage_skill"] = "冰冻伤害",
  ["#diy__ice_damage_skill-invoke"] = "你可以防止对 %dest 造成的冰冻伤害，改为依次弃置其两张牌",
}

return skill
